home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / fifo11.zip / UARTTYPE.ASM < prev    next >
Assembly Source File  |  1991-04-23  |  3KB  |  117 lines

  1. title "UART Detector"
  2. page 60, 132
  3.  
  4. ; comments -- the WRITE function is left up to your own implementation
  5. ; v1.1 Toad Hall Tweak, May 91
  6. ;    Yeah, well, we can do that.
  7. ;    David Kirschbaum
  8. ;    Toad Hall
  9. ;    kirsch%maxemail@uunet
  10.  
  11. ; constants
  12.  
  13. BIOSdseg    equ    40h        ; data segment for BIOS
  14. i        equ    1        ; COM PORT (1-4)
  15.  
  16.     .model    tiny            ; tiny model (.COM)
  17.     .code
  18.     org    100h            ; .COM files start at 100h
  19.  
  20. entry:
  21.     jmp    start            ; jump to start of progarm
  22.  
  23. ; variables
  24.  
  25. xword        dw    ?
  26. xbyte2        db    ?
  27. xbyte3        db    ?
  28.  
  29. jmp_table   dw      uart_8250_or_16450, uart_unknown, uart_16550, uart_16550a
  30.  
  31. ; ------------------------ MAIN ------------------------------
  32.  
  33. start    proc
  34.     mov    ax, BIOSdseg
  35.     mov    es, ax            ; move bios data segment into ES
  36.     mov    dx, es:[2*i-2]        ; get offset for serial port
  37.     mov    xword, dx        ; xword := serial port base address
  38.     add    dx, 2            ; dx := dx + 2
  39.     in    al, dx            ; al := port [dx]
  40.     mov    xbyte2, al        ; xbyte2 := al
  41.     mov    al, 0c1h        ; al := $C1
  42.     out    dx, al            ; port [dx] := al
  43.     in    al, dx            ; al := port [dx]
  44.     and    al, 0c0h        ; al := (al AND $C0)
  45.     mov    cl, 5            ; cl := 5
  46.     shr    al, cl            ; al := (al shr 5) (5 for word jmp)
  47.     xor    ah,ah            ; ah := 0            v1.1
  48.     mov    bp, ax            ; bp := ax (al)
  49.     mov    al, xbyte2        ; al := xbyte2
  50.     out    dx, al            ; port [dx] := al
  51.     jmp    CS:[jmp_table+bp]    ;                v1.1
  52.  
  53. uart_8250_or_16450:
  54.     mov    dx, xword        ; dx := xword
  55.     add    dx, 7            ; dx := dx + 7
  56.     in    al, dx            ; al := port [dx]
  57.     mov    xbyte2, al        ; xbyte2 := al
  58.     mov    al, 0fah        ; al := $FA
  59.     out    dx, al            ; port [dx] := al
  60.     in    al, dx            ; al := port [dx]
  61.     cmp    al, 0fah        ; if (al <> $FA)
  62.     jne    uart_16450        ; then uart is 16450
  63.     mov    al, 0afh        ; al := $AF
  64.     out    dx, al            ; port [dx] := al
  65.     in    al, dx            ; al := port [dx]
  66.     cmp    al, 0afh        ; if (al <> $AF)
  67.     jne    uart_8250        ; then uart is 8250
  68.     mov    al, xbyte2        ; else al := xbyte2
  69.     out    dx, al            ; port [dx] := al
  70.     jmp    short uart_16450    ; uart is 16450
  71.  
  72. uart_8250:
  73. ;    write    "8250"            ; display "8250"
  74. ;    jmp    exit
  75.  
  76.     call    Exit
  77.     db    '8250$'            ; display "8250"
  78.  
  79. uart_16450:
  80. ;    write    "16450"            ; display "16450"
  81. ;    jmp    exit
  82.  
  83.     call    Exit
  84.     db    '16450$'        ;display "16450"
  85.  
  86. uart_unknown:
  87. ;    write    "???"            ; display "unknown"
  88. ;    jmp    exit
  89.  
  90.     call    Exit
  91.     db    '???$'            ;display "unknown"
  92.  
  93. uart_16550:
  94. ;    write    "16550"            ; display "16550"
  95. ;    jmp    exit
  96.  
  97.     call    Exit
  98.     db    '16550$'        ;display "16550"
  99.  
  100. uart_16550a:
  101. ;    write    "16550A"        ; display "16550A"
  102. ;    jmp    exit
  103.  
  104.     call    Exit
  105.     db    '16550A$'        ;display "16550A"
  106.  
  107. Exit:
  108.     pop    dx            ;msg address            v1.1
  109.     mov    ah,9            ;display msg in DX        v1.1
  110.     int    21H            ;via DOS            v1.1
  111.  
  112.     mov    ax, 4c00h        ;terminate
  113.     int    21h
  114. start    endp                ; end of proc
  115.  
  116. END    entry                ; end of program
  117.